package edu.sctu.zhengsenwen.month201506.day20150614.textthreadutil;

/**
 * Created by user15 on 2015/6/14.
 */

//通过集成Thread接口创建线程
public class SimpleThread extends Thread {


    //设置线程的标题
    public SimpleThread(String string) {

        super(string);
    }

    //重载线程的方法
    public void run() {

        for (int i = 0; i < 8; i++) {

            System.out.println(i + "\t" + getName());

            //让程序暂停执行时间 观察运行变化
            try {
                sleep((long) (Math.random() * 1000));
            } catch (InterruptedException e) {
            }

            //提示线程的完备信息
            System.out.println(getName() + "完成");
        }
    }
}


